/**
 * 
 */
package com.jinmei.remote.util;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.Node;

/**
 * @author richard
 *
 */
public class XMLUtils {
	
	public static Node getNodeByTagName(String xmlBody, String tagName) {
		DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
		
		try {
			DocumentBuilder dombuilder = domFactory.newDocumentBuilder();
			InputStream is = new ByteArrayInputStream(xmlBody.getBytes("UTF-8"));
			Document doc = dombuilder.parse(is);
			
			return doc.getElementsByTagName(tagName).item(0);
		} catch (Exception e) {
		}
		return null;
	}

}
